//
//  mycarsViewController.m
//  car
//
//  Created by chenxu on 15/3/18.
//  Copyright (c) 2015年 chenxu. All rights reserved.
//

#import "mycarsViewController.h"
#import "changecarViewController.h"
@interface mycarsViewController ()

@end

@implementation mycarsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _carlistview = [[CarListView alloc]initWithFrame:CGRectMake(0, 0, kScreen_Width, self.view.frame.size.height-62) cars:nil selectblock:^(Car *car) {
        [Login selectCar:car];
        
        //返回上一页
        NSInteger count = [self.navigationController.viewControllers count];
        [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:count-2] animated:YES ];
        
    } modifyblock:^(Car *car) {
        [self performSegueWithIdentifier:@"modifyCarFromMyCarsView" sender:car];
    } pushblock:^{
        [self performSegueWithIdentifier:@"pushFromMyCarsView" sender:nil];

    }];
    [self.view addSubview:_carlistview];

    
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    [_carlistview refreshUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    NSString* kind = segue.identifier;
    
    if ([kind isEqualToString:@"modifyCarFromMyCarsView"]) {
        changecarViewController* nextview = [segue destinationViewController];
        nextview.car = (Car*)sender;
    }
}


@end
